<!--
 * @Author       :
 * @Date         : 2022-04-06 22:35:55
 * @LastEditors  : Please set LastEditors
 * @LastEditTime : 2022-04-07 21:44:04
 * @Description  : 请填写简介
-->
<template>
  <div @click="onToggle">
    <svg-icon :icon="isFullScreen ? 'exit-fullscreen' : 'fullscreen'"></svg-icon>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import screenfull from 'screenfull'

// 是否全屏
const isFullScreen = ref(false)

// 事件
const onToggle = () => {
  screenfull.toggle()
}
/**
 * 监听 screenfull 变化
 */
const change = () => {
  isFullScreen.value = screenfull.isFullscreen
  console.log('🚀 ~ file: index.vue ~ line 30 ~ change ~ screenfull.isFullScreen', screenfull.isFullscreen)
}
onMounted(() => {
  screenfull.on('change', change)
})
onUnmounted(() => {
  screenfull.off('change', change)
})

</script>

<style lang="scss" scoped>

</style>
